﻿Public Class frmViewEmployee

    ' ***************************************************************
    ' ************************ Private  Subs ************************
    ' ***************************************************************

    ' Loads data in the textboxes

    Private Sub frmManageEmployee_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            ' Make db textbox readonly
            EmployeeIDTextBox.ReadOnly = True
            EmployeeNameTextBox.ReadOnly = True

            ' Hide the labels for the options
            lblAdd.Visible = False
            lblDelete.Visible = False

            ' Hides all the main menu labels

            lblHome.Visible = False
            lblVisit.Visible = False
            lblSurvey.Visible = False
            lblStatistics.Visible = False
            lblInventory.Visible = False
            'lblEmployee.Visible = False
            lblClose.Visible = False

            ' Hides all the labels from the navigation menu

            lblFirst.Visible = False
            lblBack.Visible = False
            lblNext.Visible = False
            lblLast.Visible = False

            ' Add picture to the menu buttons

            btnView.Image = GeneralImageSet.Images("Info")
            btnDelete.Image = GeneralImageSet.Images("Delete")
            btnAdd.Image = GeneralImageSet.Images("AddNew")


            ' Add picture to the navigation set

            btnFirst.Image = NavigationImageSet.Images("First")
            btnBack.Image = NavigationImageSet.Images("Back")
            btnNext.Image = NavigationImageSet.Images("Forward")
            btnLast.Image = NavigationImageSet.Images("Last")



            ' Load data in textboxes
            Me.EmployeeTableAdapter.Fill(Me.Atlantic_toyota_atm_dbDataSet.employee)
            ' Load data in textboxes
            Me.EmployeeTableAdapter.Fill(Me.Atlantic_toyota_atm_dbDataSet.employee)
            ' Load data in textboxes
            Me.EmployeeTableAdapter.Fill(Me.Atlantic_toyota_atm_dbDataSet.employee)

            lblCurrentPosition.Text = System.Convert.ToString(Me.EmployeeBindingSource.Position + 1 & _
                                      " of " & Me.EmployeeBindingSource.Count)
        Catch ex As Exception
            MessageBox.Show("For some reason frmViewEmployees could not " & _
                            "load the values into the textboxes", "Error", _
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
        End Try
    End Sub

    ' When the form leaves or comes back this will 
    ' ensure that the data  will always be updated

    Private Sub LoadNewValues(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.VisibleChanged
        ' Load data in textboxes
        Me.EmployeeTableAdapter.Fill(Me.Atlantic_toyota_atm_dbDataSet.employee)
        ' Load data in textboxes
        Me.EmployeeTableAdapter.Fill(Me.Atlantic_toyota_atm_dbDataSet.employee)
        ' Load data in textboxes
        Me.EmployeeTableAdapter.Fill(Me.Atlantic_toyota_atm_dbDataSet.employee)

        lblCurrentPosition.Text = Me.EmployeeBindingSource.Position + 1 & _
                  " of " & Me.EmployeeBindingSource.Count.ToString
    End Sub


    '************************************************
    ' Show the label for the items on the main menu *
    '************************************************


    Private Sub btnBack_MouseOver(ByVal sender As System.Object, _
              ByVal e As System.EventArgs) Handles btnBack.MouseHover
        btnBack.Image = NavigationImageSet.Images("BackSelected")
        lblBack.Visible = True
    End Sub

    Private Sub btnLast_MouseOver(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles btnLast.MouseHover
        btnLast.Image = NavigationImageSet.Images("LastSelected")
        lblLast.Visible = True
    End Sub

    Private Sub btnNext_MouseOver(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles btnNext.MouseHover
        btnNext.Image = NavigationImageSet.Images("ForwardSelected")
        lblNext.Visible = True
    End Sub

    Private Sub btnFirst_MouseOver(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles btnFirst.MouseHover
        btnFirst.Image = NavigationImageSet.Images("FirstSelected")
        lblFirst.Visible = True
    End Sub


    '************************************************
    ' Hide the label for the items on the main menu *
    '************************************************

    Private Sub btnBack_MouseLeave(ByVal sender As System.Object, _
              ByVal e As System.EventArgs) Handles btnBack.MouseLeave
        btnBack.Image = NavigationImageSet.Images("Back")
        lblBack.Visible = False
    End Sub

    Private Sub btnLast_MouseLeave(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles btnLast.MouseLeave
        btnLast.Image = NavigationImageSet.Images("Last")
        lblLast.Visible = False
    End Sub

    Private Sub btnNext_MouseLeave(ByVal sender As System.Object, _
      ByVal e As System.EventArgs) Handles btnNext.MouseLeave
        btnNext.Image = NavigationImageSet.Images("Forward")
        lblNext.Visible = False
    End Sub

    Private Sub btnFirst_MouseLeave(ByVal sender As System.Object, _
          ByVal e As System.EventArgs) Handles btnFirst.MouseLeave
        btnFirst.Image = NavigationImageSet.Images("First")
        lblFirst.Visible = False
    End Sub


    '************************************************
    ' Show the label for the items on the main menu *
    '************************************************

    Private Sub btnHome_MouseOver(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnHome.MouseHover
        lblHome.Visible = True
    End Sub

    Private Sub btnVisit_MouseOver(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnVisit.MouseHover
        lblVisit.Visible = True
    End Sub

    Private Sub btnSurvey_MouseOver(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnSurvey.MouseHover
        lblSurvey.Visible = True
    End Sub

    Private Sub btnStatistics_MouseOver(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnStatistics.MouseHover
        lblStatistics.Visible = True
    End Sub

    Private Sub btnInventory_MouseOver(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnInventory.MouseHover
        lblInventory.Visible = True
    End Sub

    'Private Sub btnEmployee_MouseOver(ByVal sender As System.Object, _
    '              ByVal e As System.EventArgs) Handles btnEmployee.MouseHover
    '    lblEmployee.Visible = True
    'End Sub

    Private Sub btnClose_MouseOver(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnClose.MouseHover
        lblClose.Visible = True
    End Sub


    '**************************************
    ' Hides the labels from the main menu *
    '**************************************


    Private Sub btnHome_MouseLeave(ByVal sender As System.Object, _
              ByVal e As System.EventArgs) Handles btnHome.MouseLeave
        lblHome.Visible = False
    End Sub

    Private Sub btnVisit_MouseLeave(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnVisit.MouseLeave
        lblVisit.Visible = False
    End Sub

    Private Sub btnSurvey_MouseLeave(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnSurvey.MouseLeave
        lblSurvey.Visible = False
    End Sub

    Private Sub btnStatistics_MouseLeave(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnStatistics.MouseLeave
        lblStatistics.Visible = False
    End Sub

    Private Sub btnInventory_MouseLeave(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnInventory.MouseLeave
        lblInventory.Visible = False
    End Sub

    'Private Sub btnEmployee_MouseLeave(ByVal sender As System.Object, _
    '              ByVal e As System.EventArgs) Handles btnEmployee.MouseLeave
    '    lblEmployee.Visible = False
    'End Sub

    Private Sub btnClose_MouseLeave(ByVal sender As System.Object, _
                  ByVal e As System.EventArgs) Handles btnClose.MouseLeave
        lblClose.Visible = False
    End Sub





    ' Shows label for the view option

    Private Sub btnAdd_MouseOver(ByVal sender As System.Object, _
                      ByVal e As System.EventArgs) Handles btnAdd.MouseHover
        lblAdd.Visible = True
    End Sub

    ' Shows label for the delete option

    Private Sub btnDelete_MouseOver(ByVal sender As System.Object, _
                      ByVal e As System.EventArgs) Handles btnDelete.MouseHover
        lblDelete.Visible = True
    End Sub

    ' Hides label for the view option

    Private Sub btnAdd_MouseLeave(ByVal sender As System.Object, _
                      ByVal e As System.EventArgs) Handles btnAdd.MouseLeave
        lblAdd.Visible = False
    End Sub

    ' Hides label for the delete option

    Private Sub btnDelete_MouseLeave(ByVal sender As System.Object, _
                      ByVal e As System.EventArgs) Handles btnDelete.MouseLeave
        lblDelete.Visible = False
    End Sub

    ' Closes all forms

    Private Sub btnClose_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        CloseAllForms()
    End Sub

    ' Switch Forms

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        SwitchForm(My.Forms.frmAddEmployee)
    End Sub

    Private Sub btnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDelete.Click
        SwitchForm(My.Forms.frmDeleteEmployee)
    End Sub

    ' Move pointer to the first element

    Private Sub btnFirst_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFirst.Click
        EmployeeBindingSource.MoveFirst()
        lblCurrentPosition.Text = Me.EmployeeBindingSource.Position + 1 & _
                          " of " & Me.EmployeeBindingSource.Count.ToString
    End Sub

    ' Move pointer to the last element

    Private Sub btnLast_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLast.Click
        EmployeeBindingSource.MoveLast()
        lblCurrentPosition.Text = Me.EmployeeBindingSource.Position + 1 & _
                          " of " & Me.EmployeeBindingSource.Count.ToString
    End Sub

    ' Move pointer to the previous element

    Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnBack.Click
        EmployeeBindingSource.MovePrevious()
        lblCurrentPosition.Text = Me.EmployeeBindingSource.Position + 1 & _
                          " of " & Me.EmployeeBindingSource.Count.ToString
    End Sub

    ' Move pointer to the next element

    Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNext.Click
        EmployeeBindingSource.MoveNext()
        lblCurrentPosition.Text = Me.EmployeeBindingSource.Position + 1 & _
                          " of " & Me.EmployeeBindingSource.Count.ToString
    End Sub


    Private Sub btnClose_Visit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Dim Confirmation As MsgBoxResult
        Confirmation = MessageBox.Show("Unsaved changes will be lost. Are you sure you want to exit?", _
                                       "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
        If Confirmation = MsgBoxResult.Yes Then
            CloseAllForms()
        End If
    End Sub

    Private Sub btnHome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnHome.Click
        SwitchForm(My.Forms.frmMain)
    End Sub

    Private Sub btnVisit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnVisit.Click
        SwitchForm(My.Forms.frmQuickVisit)
    End Sub

    Private Sub btnSurvey_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSurvey.Click
        SwitchForm(My.Forms.frmSurvey)
    End Sub

    Private Sub btnStatistics_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStatistics.Click
        SwitchForm(My.Forms.frmStatistics)
    End Sub

    Private Sub btnInventory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnInventory.Click
        SwitchForm(My.Forms.frmViewInventory)
    End Sub
End Class